package com.ruoyi.kindergarten.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kindergarten.domain.EnvironmentIndicator;
import com.ruoyi.kindergarten.service.IEnvironmentIndicatorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 环境指标记录Controller
 * 
 * @author ruoyi
 * @date 2025-10-26
 */
@RestController
@RequestMapping("/kindergarten/environmentIndicator")
public class EnvironmentIndicatorController extends BaseController
{
    @Autowired
    private IEnvironmentIndicatorService environmentIndicatorService;

    /**
     * 查询环境指标记录列表
     */
    @PreAuthorize("@ss.hasPermi('kindergarten:environmentIndicator:list')")
    @GetMapping("/list")
    public TableDataInfo list(EnvironmentIndicator environmentIndicator)
    {
        startPage();
        List<EnvironmentIndicator> list = environmentIndicatorService.selectEnvironmentIndicatorList(environmentIndicator);
        return getDataTable(list);
    }

    /**
     * 导出环境指标记录列表
     */
    @PreAuthorize("@ss.hasPermi('kindergarten:environmentIndicator:export')")
    @Log(title = "环境指标记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EnvironmentIndicator environmentIndicator)
    {
        List<EnvironmentIndicator> list = environmentIndicatorService.selectEnvironmentIndicatorList(environmentIndicator);
        ExcelUtil<EnvironmentIndicator> util = new ExcelUtil<EnvironmentIndicator>(EnvironmentIndicator.class);
        util.exportExcel(response, list, "环境指标记录数据");
    }

    /**
     * 获取环境指标记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('kindergarten:environmentIndicator:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(environmentIndicatorService.selectEnvironmentIndicatorById(id));
    }

    /**
     * 新增环境指标记录
     */
    @PreAuthorize("@ss.hasPermi('kindergarten:environmentIndicator:add')")
    @Log(title = "环境指标记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EnvironmentIndicator environmentIndicator)
    {
        return toAjax(environmentIndicatorService.insertEnvironmentIndicator(environmentIndicator));
    }

    /**
     * 修改环境指标记录
     */
    @PreAuthorize("@ss.hasPermi('kindergarten:environmentIndicator:edit')")
    @Log(title = "环境指标记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EnvironmentIndicator environmentIndicator)
    {
        return toAjax(environmentIndicatorService.updateEnvironmentIndicator(environmentIndicator));
    }

    /**
     * 删除环境指标记录
     */
    @PreAuthorize("@ss.hasPermi('kindergarten:environmentIndicator:remove')")
    @Log(title = "环境指标记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(environmentIndicatorService.deleteEnvironmentIndicatorByIds(ids));
    }
}
